package com.yc.thread;

public class Join测试 {

    public static void main(String[] args) throws InterruptedException {

        Thread a = new Thread(){
            public void run(){
                System.out.println("A 开始线程执行");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("A 线程执行完成");
            }
        };
        a.start();

        Thread b = new Thread(){
            public void run(){
                System.out.println("B 开始线程执行");
                try {
                    Thread.sleep(1500);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("B 线程执行完成");
            }
        };
        b.start();

        //  等待 A,B 线程都执行完
        // Sleep   ,  Scanner   , join

        // 阻塞
        a.join();
        b.join();


        System.out.println("主线程执行完成");


    }


}
